gh-128595: Add test class helper to force no terminal colour#128687
Merged
hugovk merged 10 commits intopython:mainfrom Jan 13, 2025
Merged
gh-128595: Add test class helper to force no terminal colour#128687hugovk merged 10 commits intopython:mainfrom
hugovk merged 10 commits intopython:mainfrom
Conversation
Member
serhiy-storchaka
left a comment
There was a problem hiding this comment.
- You can disable colorizing for the whole class in
setUpClass()instead ofsetUp(). - Would not it be simpler to implement the core functionality as a generator-based context manager? You can use
enterContext()orenterClassContext()with it. - You can use
test.support.os_helper.EnvironmentVarGuard()to restore the environment andtest.support.swap_attr()to restore_colorize.can_colorize.
You can also implement this as a mixin instead of patching a method (use a super() call in an overridden method). I do not say that it would be better, but it is just an alternative which you could have overlooked.
vstinner
reviewed
Jan 10, 2025
…ce_not_colorized_test_class
vstinner
reviewed
Jan 10, 2025
Member
vstinner
left a comment
There was a problem hiding this comment.
Oh nice, the new code is more readable, I prefer context managers :-)
serhiy-storchaka
approved these changes
Jan 10, 2025
Member
serhiy-storchaka
left a comment
There was a problem hiding this comment.
LGTM. Much clearer now!
erlend-aasland
approved these changes
Jan 13, 2025
This comment was marked as outdated.
This comment was marked as outdated.
|
Sorry, @hugovk, I could not cleanly backport this to |
Member
Author
|
Thanks for the reviews! |
hugovk
added a commit
to hugovk/cpython
that referenced
this pull request
Jan 13, 2025
…lour (pythonGH-128687) (cherry picked from commit afb9dc8) Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
|
GH-128778 is a backport of this pull request to the 3.13 branch. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split out from #128498, as requested at #128498 (comment).